{template admin/header}
<script type="text/javascript" src="static/js/imgupload.js"></script>
<script type="text/javascript">
    $(function(){
        $('#publisher_files').uploadify({
            'uploader':'{conf site_url}/images/uploadify/uploadify.swf?id=&random=' + Math.random(), 
            'script':'{echo urlencode({conf site_url}."/ajax.php?mod=uploadify&code=uploadimg")}', 
            'cancelImg':'{conf site_url}/images/uploadify/cancel.png', 
            'buttonImg':'{conf site_url}/images/uploadify/upload.gif', 
            'width':58, 
            'height':58, 
            'multi':true, 
            'auto':true, 
            'sizeLimit':'{conf image_size_limit}', 
            'fileExt':'*.jpg;*.png;*.gif;*.jpeg', 
            'fileDesc':'请选择图片文件(*.jpg;*.png;*.gif;*.jpeg)', 
            'queueID':'uploadifyQueueDiv', 
            'wmode':'transparent', 
            'fileDataName':'image', 
            'queueSizeLimit':'1', 
            'simUploadLimit':1, 
            'scriptData':{'cookie_auth':'{echo urlencode(jsg_getcookie("auth"))}'}, 
            'onSelect':function(event, ID, fileObj){}, 
            'onSelectOnce':function(event, data){ }, 
            'onProgress':function(event, ID, fileObj, data){return false; }, 
            'onComplete':function(event, ID, fileObj, response, data){
                eval('var r =' + response + ';'); 
                if (r.done){
                    var rv = r.retval; 
                    if (rv.id > 0 && rv.src.length > 0) {
                        var idval = ('undefined' == typeof (rv.id) ? 0 : rv.id);
                        var srcval = ('undefined' == typeof (rv.src) ? 0 : rv.src);
                        var imageIdsCount = 0;
                        $(".upimg_img").each(function() {
                            imageIdsCount += 1;
                        });
                        if (imageIdsCount >= 1) {
                            MessageBox('warning', '本次图片数量超过限制了');
                            return false;
                        }
                        $('#viewImgDivActivity').append("<div class='upimg_img' id='upimg_" + idval + "'><input type='hidden' name='topic' value='" + idval + "' /><input type='hidden' name='files' value='" + srcval + "' /><img src='" + srcval + "'/><a href='javascript:void(0);' onclick='imageUploadifyDelete(" + idval + "); return false;' title='删除图片' class='u-del'>X</a></div>");
                        //imageUploadifyComplete('{$h_key}', rv.id, rv.src, fileObj.name); 
                    }
                }
            }, 
            
        }); 
    });
</script>
<script src="static/js/date/WdatePicker.js" type="text/javascript"></script>
<div class="mt10">
<style type="text/css">
    .radio_uid{margin: 10px;}
    .tableborder td{padding: 0px;}
</style>
    <form action="{$action}" method="post" enctype="multipart/form-data" name="form1" id="form1">
        <table cellspacing="1" cellpadding="4" width="100%" align="center" class="tableborder">
            <tr class="header">
                <td colspan="2">{$title}</td>
            </tr>
            <tr>
                <td width="13%" bgcolor="#F8F8F8">&nbsp;</td>
                <td width="87%" bgcolor="#FFFFFF">&nbsp;</td>
            </tr>
            <tr>
                <td width="13%" bgcolor="#F8F8F8">搜索用户</td>
                <td bgcolor="#FFFFFF">
                    <input id="username" type="text" value="" name="username">
                    <input id="check_PublishBox_uid" type="hidden" value="" name="check_PublishBox_uid">
                    <input id="PublishBox_type" type="hidden" value="1" name="PublishBox_type">
                    <input type="submit" class="adminTopsearchbutton" name="usernamesubmit" value="搜索">
                </td>
            </tr>
            <tr>
                <td width="13%" align="center" bgcolor="#F8F8F8">发表用户：</td>
                <td bgcolor="#FFFFFF" id="users">
                    
                </td>
            </tr>
            <tr>
                <td width="13%" align="center" bgcolor="#F8F8F8">示意图：</td>
                <td bgcolor="#FFFFFF" id="users">
                    <input type="file" name="images" id="publisher_files" >（<span class="img_size">大小：640*255，只限一张</span>）
                    <div id="viewImgDivActivity"></div>
                </td>
            </tr>
            <tr>
                <td width="13%" align="center" bgcolor="#F8F8F8">开始时间</td>
                <td bgcolor="#FFFFFF">
                    <input type="text" id="stime" name="stime" readonly="readonly" class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd  HH:mm'});">
                </td>
            </tr>
            <tr>
                <td width="13%" align="center" bgcolor="#F8F8F8">结束时间</td>
                <td bgcolor="#FFFFFF">
                    <input type="text" id="etime" name="etime" readonly="readonly" class="Wdate" onClick="WdatePicker({dateFmt: 'yyyy-MM-dd  HH:mm'});">（必须输入，即：超过该时间后，自动下架。）
                </td>
            </tr>
            <tr>
                <td width="13%" align="center" bgcolor="#F8F8F8">内容:</td>
                <td bgcolor="#FFFFFF">
                    <input type="hidden" name='topic_type' value="1" />
                    {template admin/topic_publish}  
                </td>
            </tr>
            
        </table>

    </form>

</div>
<script type="text/javascript">
    $(function() {
        $("input[name=usernamesubmit]").click(function() {
            var username = $("input[name=username]").val();
            $.post("ajax.php?mod=member&code=select_nickname", {
                nickname: username
                },
                function(ret) {
                    var json = $.parseJSON(ret);
                    if(json && json.done){
                        var list = json.retval;
                        var html = '';
                        for (var i = 0, len = list.length; i < len; i++) {
                            var data = list[i];
                            html += '<input type="radio" class="radio_uid" name= "radio_uid" value="'+data.uid+'" />'+data.nickname;
                        }
                        $("#users").html(html);
                        radio_check();
                    }
                }
            );
            return false;
        });
        function radio_check(){
            $("#users").find("input[name=radio_uid]").click(function(){
                var uid = $(this).val();
                $("#check_PublishBox_uid").val(uid);
                
            });
        }
        
    })
</script>
